<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
  <link rel="stylesheet" title="Default" href="http://acm.math.spbu.ru/~sk1/colorer/my.css">

  <script src="http://acm.math.spbu.ru/~sk1/colorer/highlight.js"></script>
  <script src="http://acm.math.spbu.ru/~sk1/colorer/cpp.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
</head>

<body>

<pre><code>
/* Sergey Kopeliovich, SummerSchoolCamp 2006 */

#include &lt;stdio.h&gt;
#include &lt;assert.h&gt;

#define SQR(X) ((X) * (X))
#define ABS(A) ((A) &gt; 0 ? (A) : -(A))

#define MAX 5010
#define MAXE 20010
#define EPS 1e-6

typedef double dbl;
typedef __int64 t;

int W, H, N, St[MAX], En[MAX], Pos = 0, LN;
t X[MAX], Y[MAX], A[MAX], B[MAX], C[MAX];
dbl RX[MAXE], RY[MAXE];

int main( void )
{
  int Mi[MAX];
  t Mf[MAX];
  int i, j, la, mi, fi;
  t f, a, b, tmp;
  dbl x, y, k, mk;

  assert(freopen("football2.in", "rt", stdin));
  assert(freopen("football2.out", "wt", stdout));
  scanf("%d%d%d", &W, &H, &N);
  if (N &gt;= MAX - 5)
    while (1);
  for (i = 0; i &lt; N; i++)
    scanf("%I64d%I64d", &X[i], &Y[i]), Mf[i] = (t)1e18;
  for (i = 0; i &lt; N; i++)
  {
    for (j = i + 1; j &lt; N; j++)
    {
      f = SQR(X[j] - X[i]) + SQR(Y[j] - Y[i]);
      if (Mf[i] &gt; f) Mf[i] = f, Mi[i] = j;
      if (Mf[j] &gt; f) Mf[j] = f, Mi[j] = i;
    }
    mi = Mi[i];
    for (j = 0; j &lt; N; j++)
    {
      A[j] = X[j] - X[i];
      B[j] = Y[j] - Y[i];
      C[j] = -(A[j] * (X[j] + X[i]) + B[j] * (Y[j] + Y[i]));
      A[j] &lt;&lt;= 1, B[j] &lt;&lt;= 1;
    }
    A[N + 0] = -1, B[N + 0] = 0, C[N + 0] = 0;
    A[N + 1] = 0, B[N + 1] = 1, C[N + 1] = -H;
    A[N + 2] = 1, B[N + 2] = 0, C[N + 2] = -W;
    A[N + 3] = 0, B[N + 3] = -1, C[N + 3] = 0;
    LN = N + 4;
    St[i] = Pos;
    fi = mi;
    x = (X[i] + X[mi]) * 0.5, y = (Y[i] + Y[mi]) * 0.5;
    do
    {
      a = B[mi], b = -A[mi], la = mi;
      mi = 0, mk = 1e20;
      for (j = 0; j &lt; LN; j++)
        if (j != la && (tmp = A[j] * a + B[j] * b) &gt; 0)
        {
          k = -(A[j] * x + B[j] * y + C[j]);
          if (k &gt; EPS)
            if (k &lt; mk * tmp - EPS || (ABS(mk * tmp - k) &lt; EPS && A[j] * B[mi] - B[j] * A[mi] &gt; 0))
              mk = k / tmp, mi = j;
        }
      x += a * mk, y += b * mk;
      assert(Pos &lt; MAXE);
      RX[Pos] = x, RY[Pos++] = y;
    } while (mi != fi);
    En[i] = Pos;
  }
  for (i = 0; i &lt; N; i++)
  {
    int len = En[i] - St[i];
    dbl *rx = &RX[St[i]], *ry = &RY[St[i]];
    printf("%d\n", len);
    for (mi = j = 0; j &lt; len; j++)
      if (rx[j] &lt; rx[mi] - EPS || (ABS (rx[j] - rx[mi])&lt;EPS && ry[j] &lt; ry[mi]-EPS))
        mi = j;
    for (j = 0; j &lt; len; j++)
      printf("%.18lf %.18lf\n", rx[(mi - j + len) % len], ry[(mi - j + len) % len]);
  }
  return 0;
}

</code></pre>

</body>
</html>

<font style="visibility:hidden">
